﻿
	import flash.display.Sprite;
	import flash.events.TextEvent;
	import flash.text.TextField;
	import flash.text.TextFieldType;
	import flash.text.TextFieldAutoSize;
	import flash.text.TextFormat;
	import flash.display.BlendMode;
	import flash.text.Font;
	
	import caurina.transitions.Tweener;
	
	var _txtExample:TextField;
	var _oTweenFadeIn:Object;
	var _oTweenFadeOut:Object;


	this.mouseEnabled = false;

	var _txtInputText:TextField = new TextField();
	_txtInputText.type = TextFieldType.INPUT;
	_txtInputText.border = true;
	_txtInputText.borderColor = 0xFFFFFF;
	_txtInputText.width = this.stage.stageWidth;
	_txtInputText.height = 25;
	_txtInputText.text = "Replace this text";

	_txtInputText.addEventListener(TextEvent.TEXT_INPUT, onTextInput, false, 0, true);

	_txtExample = new TextField();

	var tfExample:TextFormat = new TextFormat("Arial", 50, 0xFFFFFF, true);
	_txtExample.defaultTextFormat = tfExample;
	_txtExample.autoSize = TextFieldAutoSize.LEFT;
	_txtExample.wordWrap = true;
	_txtExample.embedFonts = true;
	_txtExample.x = 5;
	_txtExample.y = 50;
	_txtExample.width = this.stage.stageWidth;

	_txtExample.height = 100;

	var _txtTwo:TextField = new TextField();
	_txtTwo.defaultTextFormat = tfExample;
	_txtTwo.autoSize = TextFieldAutoSize.LEFT;
	_txtTwo.textColor = 0x333333;
	_txtTwo.wordWrap = true;
	_txtTwo.embedFonts = true;
	_txtTwo.x = 10;
	_txtTwo.y = 60;
	_txtTwo.width = this.stage.stageWidth;


	_oTweenFadeIn = 
	{
		time				:	1.0,
		alpha				:	1,
		delay				:	.5,
		transition			:	"linear",
		onComplete			:	function():void
								{
									Tweener.addTween(this, _oTweenFadeOut);
								} // END FUNCTION
	}; // END OBJECT

	_oTweenFadeOut = 
	{
		time				:	1.0,
		alpha				:	0,
		delay				:	.5,
		transition			:	"linear",
		onComplete			:	function():void
								{
									Tweener.addTween(this, _oTweenFadeIn);
								} // END FUNCTION
	}; // END OBJECT

	addChild(_txtInputText);
	addChild(_txtTwo);
	addChild(_txtExample);

	_txtExample.text = _txtInputText.text;
	_txtTwo.text = _txtInputText.text;

	Tweener.addTween(_txtExample, _oTweenFadeIn);
	Tweener.addTween(_txtTwo, _oTweenFadeIn);

		
	function onTextInput(e:TextEvent):void 
	{
		_txtExample.text = e.target.text + e.text;
		_txtTwo.text = e.target.text + e.text;
	}
		